<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>model</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .bord{
            border: 1px dashed #ee2602;
            width: 90%;
            margin: 20px auto;
        }
        .title{
            font-size: 20px;
            font-weight: bold;
            margin: 20px;
        }
        .introduce{
            font-size: 16px;
            margin: 0 0 20px 50px;
        }
        .red{
            color: red;
        }
    </style>
    <script>
        var    arr   =    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

        window.onload = function () {
            document.getElementById('a').onclick = function () {
                num = 0;
                for (var i = 0; i<arr.length;i++){
                    var dd = arr[i];
                    num = num + dd - 0;
                }
                alert(num);
            }
        };
    </script>
</head>
<body>
<div class="bord">
    <div class="title">数组求和</div>
    <div class="introduce">
        已知数组，求数组之和？<br/>
        var    arr   =    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
    </div>
</div>
<div class="bord">
    <div class="title">演示效果</div>
    <button id="a" class="introduce">结果</button>
</div>
<div class="bord">
    <div class="title">代码</div>
    <div class="introduce">
        <pre>
             &lt;script&gt;
        var    arr   =    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

        window.onload = function () {
            document.getElementById('a').onclick = function () {
                num = 0;
                for (var i = 0; i&lt;arr.length;i++){
                    var dd = arr[i];
                    num = num + dd - 0;
                }
                alert(num);
            }
        };
    &lt;/script&gt;
        </pre>
    </div>
</div>
</body>
</html>